<?php
//SKI class for monitoring 
class MonitoringSKI extends Transaksi
{
	public $ski_no;
	public $nota_divmum;
	
	public function rules() {
		$rules = parent::rules();
		$rules[] = array('ski_no, nota_divmum', 'safe', 'on'=>'search');
		
		return $rules;
	}
	
	public function searchSKI($nilai_divisi, $nilai_status) {
		$criteria=new CDbCriteria;

		$criteria->with = array('transaksiSkis', 'transaksiAtributs' ,'idStatus');
		
		$criteria->compare('id_divisi',$nilai_divisi);
		$criteria->compare('transaksiSkis.ski_no',$this->ski_no,true);
		$criteria->compare('pekerjaan',$this->pekerjaan,true);
		$criteria->compare('rekanan',$this->rekanan,true);
		$criteria->compare('kurs',$this->kurs,true);
		$criteria->compare('nilai',$this->nilai,true);
		$criteria->compare('nilai_rupiah',$this->nilai_rupiah,true);
		$criteria->compare('transaksiAtributs.nota_divmum_no',$this->nota_divmum,true);
		$criteria->compare('idStatus.keterangan',$nilai_status);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
			'pagination' => array (
                  'pageSize' => 30,
            ),
			'sort'=>array(
            	'defaultOrder'=>'t.id ASC',
        	),
		));
	}
	
	public function searchSKIPending($nilai_divisi) {
		return $this->searchSKI($nilai_divisi, 'Pending');
	}
	
	public function searchSKIApproved($nilai_divisi) {
		return $this->searchSKI($nilai_divisi, 'Approved');
	}
	
	public function searchSKIRejected($nilai_divisi) {
		return $this->searchSKI($nilai_divisi, 'Rejected');
	}
	
}

?>